/**
 * Created by Panda on 2017/2/12
 */
(function () {
    'use strict';

    angular
        .module('com.akxx.aqzyk')
        .directive('searchBar', searchBar);

    /** @ngInject */
    function searchBar() {
        return {
            restrict: "EA",
            scope: {
                callback: '='
            },
            templateUrl: "app/directives/common/search-bar.html",
            controller: function ($scope) {
                $scope.search = function (event) {
                    if(event.keyCode === 13){
                        $scope.callback($scope.text);
                    }
                };

                $scope.clear = function () {
                    $scope.text = "";
                    $scope.callback("");
                }
            }
        }
    }

})();
